-
Notifications
You must be signed in to change notification settings - Fork 621
Refactor rate limiting to use separate read/write Redis operations #6702
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor rate limiting to use separate read/write Redis operations #6702
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
size-limit report 📦
|
44861c1 to
76c1b47
Compare
🦋 Changeset detectedLatest commit: aadc142 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
76c1b47 to
7cdf546
Compare
7cdf546 to
4221cb4
Compare
e987d55 to
9c30d3f
Compare
9c30d3f to
ffd63f4
Compare
ffd63f4 to
d5e5140
Compare
d5e5140 to
aadc142
Compare

TL;DR
Updated the rate limiting implementation to improve handling of concurrent requests and added support for custom increment values.
What changed?
getandincrByinstead of justincrincrementparameter to allow incrementing by values other than 1How to test?
Why make this change?
This change addresses race conditions that could occur with concurrent requests by separating the read and increment operations. It also adds flexibility with the new
incrementparameter, allowing services to count certain requests as multiple units against the rate limit. The improved error handling makes the system more resilient to Redis connection issues.PR-Codex overview
This PR focuses on updating the
rateLimitfunction in theservice-utilspackage to enhance its functionality by allowing custom increments and improving error handling for Redis operations.Detailed summary
get,expire, andincrBymethods to theIRedistype.incrementparameter to therateLimitfunction.get.